package com.etlmaster.executor.steps.table;

import java.util.HashMap;
import java.util.Map;

import com.etlmaster.executor.utils.JsonHelper;


public class CreateMPPTableStepMeta extends CreateTableStepMeta {
	private String serverName;

	private Map<String, Object> options;

	private String errLog;
	
	private String log;

	private String reject;

	public CreateMPPTableStepMeta(String id, String name, String step_code, String session_id, String paramStr) {
		super(id, name, step_code, session_id, paramStr);
	}

	@SuppressWarnings("unchecked")
	protected void parseParam(String paramStr) {
		super.parseParam(paramStr);

		char firstChar = paramStr.charAt(0);
		if (firstChar == '[' || firstChar == '{') {
			Map<String, Object> paramMap = (Map<String, Object>) JsonHelper.getInstance().read(paramStr);
			options = new HashMap<String, Object>();
			options.put("ip", paramMap.get("ip"));
			options.put("port", paramMap.get("port"));
			options.put("fileName", paramMap.get("fileName"));
			options.put("format", paramMap.get("format"));
			options.put("header", paramMap.get("header"));
			options.put("mode", paramMap.get("mode"));
			options.put("delimiter", paramMap.get("delimiter"));
			options.put("noescaping", paramMap.get("noescaping"));
			options.put("encoding", paramMap.get("encoding"));
		}
	}
	
	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public String getErrLog() {
		return errLog;
	}

	public void setErrLog(String errLog) {
		this.errLog = errLog;
	}

	public String getLog() {
		return log;
	}

	public void setLog(String log) {
		this.log = log;
	}

	public String getReject() {
		return reject;
	}

	public void setReject(String reject) {
		this.reject = reject;
	}

	public Map<String, Object> getOptions() {
		return options;
	}

	public void setOptions(Map<String, Object> options) {
		this.options = options;
	}
}
